<?php
class UserAction extends BaseAction {
//
//	function _initialize() {
//		$uid = Session :: get(C('USER_AUTH_KEY'));
//	}

	public function login() {
		$this->display("Index:login");
	}

	public function signIn() {
		dump($this->flag . '------------------');
		$d_user = D("User");
		$map['name'] = $_POST['name'];
		$map['password'] = $_POST['password'];
		$user = $d_user->where($map)->find();
		if (!$user) {
			dump($user . 'fail');
		} else {
			dump($user . 'success');
			Session :: set(C('USER_AUTH_KEY'), $user['id']);
			Session :: set('admin', $user['name']);
		}
		$this->display('Index:index');
	}
	
	public function signOut(){
		if(Session::is_set(C('USER_AUTH_KEY'))){
			Session::clear();
			$this->assign('jumpUrl',__URL__.'/login');
			$this->success("注销成功！");
		}else{
			$this->assign('jumpUrl',__URL__.'/login');
			$this->error('已经注销！');
		}
		$this->forward();
	}
}
?>